<?php
/**
 * @package     JBDump init
 * @version     1.2.6
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */

// include JBDump library
include 'class.jbdump.php';

// init and configuration JBDump library
JBDump::i('jbdump', array (
    
    'root'  => trim(dirname(__FILE__), 'jbdump'),
    // 'root'  => $_SERVER['DOCUMENT_ROOT'],
    // 'root'  => dirname(__FILE__),
    
    
    // file logger
    'logPath'       => false,   // absolute log path
    'logFile'       => false,   // file logname
    'serialize'     => 'print_r',  // serialize type before write to log file
                                // (none|json|serialize|print_r|var_dump) 
    'logFormat'     => "{DATETIME}\t{CLIENT_IP}\t\t{FILE}\t\t{NAME}\t\t{TEXT}", // fields in log file
    
    // profiler
    'autoProfile'   => true,    // if true, then JBDump::profiler() call automatically
                                // after a stop PHP script
    'profileToFile' => false,   // If autoProfile enabled, the profiler will be recorded in the log
                                // else show in browser
    
    // sorting (ASC)
    'sort'          => array(
        'array'     => false,   // by keys
        'object'    => true,    // by properties name
        'methods'   => true,    // by methods name
    ),
    
    // handlers
    'handler'       => array(
        'error'     => true,    // register own handler for PHP errors
        'exception' => true,    // register own handler for all exeptions
        'context'   => false,   // show context for errors
    ),
    
    
    // personal dump
    'ip'            => false,   // Address for which to work debugging
    'requestParam'  => false,   // $_REQUEST key for which to work debugging
    'requestValue'  => false,   // $_REQUEST value for which to work debugging
    
    
    // others
    'lite_mode'     => false,   // lite messages for errors and exceptions
    'stringLength'  => 50,      // cutting long string
    'maxDepth'      => 3,       // the maximum depth of the dump
    'showMethods'   => true,    // show object methods
    'allToLog'      => false,   // all dumps record to log file and don't show in browser (!experimental)
    'showArgs'      => false,   // show Args in backtrace
));

global $d;
$d = JBDump::i();

// usability methods
if (!function_exists('d')) {
    function d($var = 'JBDump::variable no set', $isDie = true, $name = '...')
    {
        $_this = JBDump::i();
        
        if ($var !== 'JBDump::variable no set') {
            if ($_this->isDebug()) {
            
                $params = array('trace' => debug_backtrace());
                $_this->dump($var, $name, $params);
                
                if ($isDie) {
                    die('JBDump_die');
                }
            }
        }

        return $_this;
    }

}

if (!function_exists('l')) {
    function l($entry, $mark = '...') {
        $params = array('trace' => debug_backtrace());
        return JBDump::log($entry, $mark, $params);
    }
}

if (!function_exists('m')) {
    function m($text) {
        return JBDump::mark($text);
    }
}

